#include "mainwindow.h"
#include <QHBoxLayout>
#include <DWidget>

DWIDGET_USE_NAMESPACE

MainWindow::MainWindow(QWidget *parent) :
    DMainWindow(parent),
    mSpinBox(new DSpinBox),
    mPushButton(new DPushButton),
    mRadius(new Radius)
{
    mSpinBox->setMaximum(60);
    mSpinBox->setMinimum(0);
    mPushButton->setText(tr("确定"));

    QHBoxLayout *box = new QHBoxLayout;
    box->addWidget(mSpinBox,20);
    box->addWidget(mPushButton,1);

    DWidget *d = new DWidget;
    d->setLayout(box);

    int height = 110;
    int widget = 400;
    this->setFixedSize(widget,height);

    setCentralWidget(d);

    int currentWindowRadius = mRadius->radius();
//    mPushButton->setText(QString::number(currentWindowRadius));
    mSpinBox->setValue(currentWindowRadius);

    connect(mPushButton,&DPushButton::clicked,this,&MainWindow::submit);
    connect(mSpinBox,&DSpinBox::editingFinished,this,&MainWindow::submit);
}

void MainWindow::submit()
{
    int value = mSpinBox->value();
    mRadius->setRadius(value);
}


